#include <stdio.h>
#include <stdlib.h>

void print_dash(int n){
	printf(" ");
	while(n--)
		printf("-");
	printf(" ");
}
void print_space(int n){
	while(n--)
		printf(" ");
}
void print_pipe(int n, char flag){
	switch(flag){
		case 'l':
			printf("|");
			print_space(n+1);
			break;
		case 'r':
			print_space(n+1);
			printf("|");
			break;
		case 'b':
			printf("|");
			print_space(n);
			printf("|");
			break;
		case 'n':
			print_space(n+2);
			break;
	}
}

void print_num(int num_to_print, int size, int cur_row){
	int is_dash = (cur_row == 0 || cur_row == 2*size+3 || cur_row == size+1);
	if(is_dash){
		switch(num_to_print){
			case 0:
				if(cur_row == size+1)
					print_space(size+2);
				else
					print_dash(size);
				break;
			case 1:
				print_space(size+2);
				break;
			case 2:
			case 3:
			case 5:
			case 6:
			case 8:
			case 9:
				print_dash(size);
				break;
			case 4:
				if(cur_row == size+1)
					print_dash(size);
				else
					print_space(size+2);
				break;
			case 7:
				if(cur_row == 0)
					print_dash(size);
				else
					print_space(size+2);
				break;
		}
	}else{
		switch(num_to_print){
			case 0:
			case 8:
				print_pipe(size, 'b');
				break;
			case 1:
				print_pipe(size, 'n');
				break;
			case 2:
				if(cur_row < size+1)
					print_pipe(size, 'r');
				else
					print_pipe(size, 'l');
				break;
			case 3:
			case 7:
				print_pipe(size, 'r');
				break;
			case 4:
				if(cur_row < size+1)
					print_pipe(size, 'b');
				else
					print_pipe(size, 'r');
				break;
			case 5:
				if(cur_row < size+1)
					print_pipe(size, 'l');
				else
					print_pipe(size, 'r');
				break;
			case 6:
				if(cur_row < size+1)
					print_pipe(size, 'l');
				else
					print_pipe(size, 'b');
				break;
			case 9:
				if(cur_row < size+1)
					print_pipe(size, 'b');
				else
					print_pipe(size, 'r');
				break;
		}
	}
}

int get_num_digits(int n){
	int num_digits = 1;
	while((n /= 10) > 1){
		num_digits++;
	}
	return(num_digits);
}

int main(int argc, char **argv){
    char in_number[6];
    int i,j;
    int rows, size, in_num_digits;
    int in_digits[7];
    while( (scanf("%d %s\n", &size, in_number))==2 && size != 0){
	rows = 2*size+3;
	i = 0;

	while(in_number[i] != '\0')
	    in_digits[i] = in_number[i] - '0';
	in_num_digits = i;
	
	for(i = 0; i <= rows; i++){
		for(j = 0; j < in_num_digits; j++){
			print_num(in_digits[j], size, i);
			printf(" ");
		}
		printf("\n");
	}	
    }
    
    return(0);
}
